/**********************************************
 * 	TestDictionary.java						  *
 *  Course: CS3343							  *
 *  Version: 2.5    Release 3				  *
 *  Last Modified : 22 MAR 2013			      *
 **********************************************/
package testChecker;


import org.junit.Before;
import junit.framework.TestCase;
import checker.Dictionary;
import org.junit.Test;


public class TestDictionary extends TestCase{

	
    @Before
	public void setUp() throws Exception {

	}
	
	//unit test for the Dictionary class
	@Test
	public void testSpellingA(){
		
		class DictionaryStub extends Dictionary{
			
			//check whether the input matches the one of the predefined words in the array 
			public boolean checkSpelling(String word){
				//String[] wordList = readFile.getWordCategory(word,"dictionary");
				
				String[] wordList = {"ahead", "baby","cat", "drill","elapse" , "freak"};

				for(int i = 0; i<wordList.length; i++)
					if(word.equalsIgnoreCase(wordList[i]))
						return true;
				
				return false;
			}
		
		};
		
		DictionaryStub dictionaryStub = new DictionaryStub();
		
		boolean result = dictionaryStub.checkSpelling("cAt");
		assertEquals(true, result);
		
	}
	
	
	@Test
	public void testSpellingB(){
		
		class DictionaryStub extends Dictionary{
			
			//check whether the input matches the one of the predefined words in the array 
			public boolean checkSpelling(String word){
				//String[] wordList = readFile.getWordCategory(word,"dictionary");
				
				String[] wordList = {"ahead", "baby","cat", "drill","elapse" , "freak" ,"drink"};
				for(int i = 0; i<wordList.length; i++)
					if(word.equalsIgnoreCase(wordList[i]))
						return true;
				
				return false;
			}
		
		};
		
		DictionaryStub dictionaryStub = new DictionaryStub();
		
		boolean result = dictionaryStub.checkSpelling("drinkss");
		assertEquals(false, result);
		
	}
	
	//test integration with the FileIO class that reads file for the Dictionary class
	@Test
	public void testIntegrationWithFileIO1(){
		Dictionary dictionary = new Dictionary();
		boolean result = dictionary.checkSpelling("aheadss");
		assertEquals(false, result);
		
	}
	
	@Test
	public void testIntegrationWithFileIO2(){
		Dictionary dictionary = new Dictionary();
		boolean result = dictionary.checkSpelling("Arizonian");
		assertEquals(true, result);
	
	}
	
	@Test
	public void testIntegrationWithFileIO3(){
		Dictionary dictionary = new Dictionary();
		boolean result = dictionary.checkSpelling("azygous");
		assertEquals(true, result);
	}
	
	@Test
	public void testIntegrationWithFileIO4(){
		Dictionary dictionary = new Dictionary();
		boolean result = dictionary.checkSpelling("CoNgRaTuLaTiOn");
		assertEquals(true, result);
	}	
	
	@Test
	public void testIntegrationWithFileIO5(){
		Dictionary dictionary = new Dictionary();
		boolean result = dictionary.checkSpelling("CoNgRaTuLaTiOnd");
		assertEquals(false, result);
	}
	
	@Test
	public void testIntegrationWithFileIO6(){
		Dictionary dictionary = new Dictionary();
		boolean result = dictionary.checkSpelling("readed");
		assertEquals(false, result);
	}
}
